function [a,b,c,d]=homework3driver()

largenumber=30;
power=[1 4 7 10 13 16 20 25];
%power=[1 4];
a=zeros(length(power),8);
b=zeros(length(power),4);
c=zeros(length(power),8);
d=zeros(length(power),8);

for p=1:length(power)
a_temp=0;
b_temp=0;
c_temp=0;
d_temp=0;
for k=1:largenumber
%	[a1,b1,c1,d1]=homework3([1 2 3 4],power(p));
%	a_temp=a_temp+a1;
%	b_temp=b_temp+b1;
%	c_temp=c_temp+c1;
%	d_temp=d_temp+d1;
end

a(p,:)=a_temp;
b(p,:)=b_temp;
c(p,:)=c_temp;
d(p,:)=d_temp;
end

a=1-a/largenumber;
b=1-b/largenumber;
c=1-c/largenumber;
d=1-d/largenumber;


load homework3alldata.mat;
x=10*log10(power);

ber_real=a;
figure;
plot(x,ber_real(:,1)','b.-',x,ber_real(:,2)','c.-',x,ber_real(:,3)','r.-',x,ber_real(:,4)','m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Known and Correlated', 'Known and Independent', 'Estimated and Correlated', 'Estimated and Independent');
title('BER rate vs SNR(dB) for BLAST System');

figure;
plot(x,ber_real(:,5),'b.-',x,ber_real(:,6),'c.-',x,ber_real(:,7),'r.-',x,ber_real(:,8),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Known and Correlated', 'Known and Independent', 'Estimated and Correlated', 'Estimated and Independent');
title('BER rate vs SNR(dB) for Alamouti Code');

ber_real=b;
figure;
plot(x,ber_real(:,1),'b.-',x,ber_real(:,2),'c.-',x,ber_real(:,3),'r.-',x,ber_real(:,4),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Known and Correlated', 'Known and Independent', 'Estimated and Correlated', 'Estimated and Independent');
title('BER rate vs SNR(dB) for Rate 1/2 System');

ber_real=c;
figure;
plot(x,ber_real(:,1),'b.-',x,ber_real(:,2),'c.-',x,ber_real(:,3),'r.-',x,ber_real(:,4),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Known and Correlated', 'Known and Independent', 'Estimated and Correlated', 'Estimated and Independent');
title('BER rate vs SNR(dB) for BLAST System');

figure;
plot(x,ber_real(:,5),'b.-',x,ber_real(:,6),'c.-',x,ber_real(:,7),'r.-',x,ber_real(:,8),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Known and Correlated', 'Known and Independent', 'Estimated and Correlated', 'Estimated and Independent');
title('BER rate vs SNR(dB) for Rate 3/4 System');

ber_real=d;
figure;
plot(x,ber_real(:,1),'b.-',x,ber_real(:,2),'c.-',x,ber_real(:,3),'r.-',x,ber_real(:,4),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('Coherent Alamouti, Correlated', 'Coherent Alamouti, Independent', 'Differential Alamouti, Correlated', 'Differential Alamouti, Independent');
title('BER rate vs SNR(dB) for Alamouti Systems');

figure;
plot(x,ber_real(:,5),'b.-',x,ber_real(:,6),'c.-',x,ber_real(:,7),'r.-',x,ber_real(:,8),'m.-');
ylabel('Bit Error Rate');
xlabel('SNR (dB)');
legend('(4,1) Cyclic Group, Correlated', '(4,1) Cyclic Group, Independent', '(4,3) Cyclic Group, Correlated', '(4,3) Cyclic Group, Independent');
title('BER rate vs SNR(dB) for Cyclic Group Schemes');
